﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataMeterDevice" @search="()=>{getTableDataMeterDevice();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DeviceCode_FormItem" prop="DeviceCode" :label="$t('message.autotrans._Model_MeterDevice_DeviceCode')">
            <el-input v-model="searchDataMeterDevice.DeviceCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DeviceName_FormItem" prop="DeviceName" :label="$t('message.autotrans._Model_MeterDevice_DeviceName')">
            <el-input v-model="searchDataMeterDevice.DeviceName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DeviceType_FormItem" prop="DeviceType" :label="$t('message.autotrans._Model_MeterDevice_DeviceType')">
            <el-select v-model="searchDataMeterDevice.DeviceType" clearable>
               <el-option key="ElectricMeter" value="ElectricMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_ElectricMeter')"></el-option>
               <el-option key="PressureMeter" value="PressureMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_PressureMeter')"></el-option>
               <el-option key="FlowMeter" value="FlowMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_FlowMeter')"></el-option>
               <el-option key="ProtectiveGasMeter" value="ProtectiveGasMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_ProtectiveGasMeter')"></el-option>
               <el-option key="GasMeter" value="GasMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_GasMeter')"></el-option>
               <el-option key="WaterMeter" value="WaterMeter" :label="$t('message.autotrans._Enum_MeterDeviceType_WaterMeter')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Location_FormItem" prop="Location" :label="$t('message.autotrans._Model_MeterDevice_Location')">
            <el-input v-model="searchDataMeterDevice.Location" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Area_FormItem" prop="Area" :label="$t('message.autotrans._Model_MeterDevice_Area')">
            <el-input v-model="searchDataMeterDevice.Area" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Manufacturer_FormItem" prop="Manufacturer" :label="$t('message.autotrans._Model_MeterDevice_Manufacturer')">
            <el-input v-model="searchDataMeterDevice.Manufacturer" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="InstallDate_FormItem" prop="InstallDate" :label="$t('message.autotrans._Model_MeterDevice_InstallDate')">
            <el-date-picker v-model="searchDataMeterDevice.InstallDate" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CommAddress_FormItem" prop="CommAddress" :label="$t('message.autotrans._Model_MeterDevice_CommAddress')">
            <el-input v-model="searchDataMeterDevice.CommAddress" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CommProtocol_FormItem" prop="CommProtocol" :label="$t('message.autotrans._Model_MeterDevice_CommProtocol')">
            <el-select v-model="searchDataMeterDevice.CommProtocol" clearable>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Status_FormItem" prop="Status" :label="$t('message.autotrans._Model_MeterDevice_Status')">
            <el-select v-model="searchDataMeterDevice.Status" clearable>
               <el-option key="Normal" value="Normal" :label="$t('message.autotrans._Enum_EquipStatusEnum_Normal')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Remark_FormItem" prop="Remark" :label="$t('message.autotrans._Model_MeterDevice_Remark')">
            <el-input v-model="searchDataMeterDevice.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_MeterDevice_CreateTime')">
            <el-date-picker v-model="searchDataMeterDevice.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_MeterDevice_UpdateTime')">
            <el-date-picker v-model="searchDataMeterDevice.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_MeterDevice_CreateBy')">
            <el-input v-model="searchDataMeterDevice.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_MeterDevice_UpdateBy')">
            <el-input v-model="searchDataMeterDevice.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/IoTManagement/MeterDevice/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/IoTManagement/MeterDevice/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/IoTManagement/MeterDevice/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/IoTManagement/MeterDevice/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/IoTManagement/MeterDevice/MeterDeviceExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefMeterDevice" v-bind="tableDataMeterDevice">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/IoTManagement/MeterDevice/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/IoTManagement/MeterDevice/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/IoTManagement/MeterDevice/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageIoTManagementMeterDeviceIndex;true;Digitalmes.IoTManagement.Controllers;MeterDevice">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { meterdeviceApi } from '/@/api/iotmanagement/meterdevice';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateMeterDevice = reactive({
    
});

const searchDataMeterDevice = ref({
        DeviceCode: '',
        DeviceName: '',
        DeviceType: undefined,
        Location: '',
        Area: '',
        Manufacturer: '',
        InstallDate: undefined,
        CommAddress: '',
        CommProtocol: undefined,
        Status: undefined,
        Remark: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefMeterDevice = ref();
const tableDataMeterDevice = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page设备编号'),key: 'MeterDevice_DeviceCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备名称'),key: 'MeterDevice_DeviceName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备类型'),key: 'MeterDevice_DeviceType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page安装位置'),key: 'MeterDevice_Location',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page所属区域'),key: 'MeterDevice_Area',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page制造商'),key: 'MeterDevice_Manufacturer',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page安装日期'),key: 'MeterDevice_InstallDate',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page通讯地址'),key: 'MeterDevice_CommAddress',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page通讯协议'),key: 'MeterDevice_CommProtocol',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page状态'),key: 'MeterDevice_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'MeterDevice_Remark',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'MeterDevice_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'MeterDevice_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'MeterDevice_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'MeterDevice_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataMeterDevice = () => {
    tableRefMeterDevice.value.doSearch(meterdeviceApi().search, searchDataMeterDevice.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataMeterDevice)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataMeterDevice)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataMeterDevice)
};

// 删除
const onDelete = (row: any) => {
    meterdeviceApi().delete([row.ID]).then(() => { getTableDataMeterDevice()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefMeterDevice.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      meterdeviceApi().delete(selectedids).then(() => { getTableDataMeterDevice()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefMeterDevice.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataMeterDevice)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataMeterDevice)
};

const onExport = () => {
	const selected = tableRefMeterDevice.value.getSelectedRows();
	if (selected.length > 0) {
		meterdeviceApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		meterdeviceApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataMeterDevice();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

